using System.Web.UI;
using System.Web.UI.HtmlControls;

namespace FluentTags
{

    public class TDTag : Tag<TDTag>
    {
        public TDTag() : base("td"){}
        
        public TDTag(string text) : this()
        {
            Controls.Add(new LiteralControl(text));
        }

        public TDTag(object value) : this()
        {
            Controls.Add(new LiteralControl(SafeString(value)));
        }
        
        
        public TDTag(Control control) : this()
        {
            Controls.Add(control);
        }
        
        
        public TDTag Abbr(string value)
        {   
            Attributes.Add("abbr", value.ToString());
            return this;
        }
        
        public TDTag Axis(string value)
        {   
            Attributes.Add("axis", value.ToString());
            return this;
        }
        
        public TDTag Colspan(int value)
        {   
            Attributes.Add("colspan", value.ToString());
            return this;
        }
        
        public TDTag Headers(string value)
        {   
            Attributes.Add("headers", value.ToString());
            return this;
        }
        
        public TDTag Rowspan(int value)
        {   
            Attributes.Add("rowspan", value.ToString());
            return this;
        }
        
        public TDTag Scope(string value)
        {   
            Attributes.Add("scope", value.ToString());
            return this;
        }
        
        
        public string AbbrAttribute
        {
            get
            {
                return Attributes["abbr"];
            }
        }
        
        public string AxisAttribute
        {
            get
            {
                return Attributes["axis"];
            }
        }
        
        public int ColspanAttribute
        {
            get
            {
                int test;
                if (int.TryParse(Attributes["colspan"], out test))
                {
                    return test;
                }

                // the default
                return 1;
            }
        }
        
        public string HeadersAttribute
        {
            get
            {
                return Attributes["headers"];
            }
        }
        
        public int RowspanAttribute
        {
            get
            {
                int test;
                if (int.TryParse(Attributes["rowspan"], out test))
                {
                    return test;
                }

                // the default
                return 1;
            }
        }
        
        public string ScopeAttribute
        {
            get
            {
                return Attributes["scope"];
            }
        }
        
        
        public ATag<TDTag> A()
        {
            var ctrl = new ATag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag A(ATag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ATag<TDTag> A(string text)
        {
            var ctrl = new ATag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public ATag<TDTag> A(Control control)
        {
            var ctrl = new ATag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public ATag<TDTag> A(object value)
        {
            return A(SafeString(value));
        }
        
        public BTag<TDTag> B()
        {
            var ctrl = new BTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag B(BTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public BTag<TDTag> B(string text)
        {
            var ctrl = new BTag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public BTag<TDTag> B(Control control)
        {
            var ctrl = new BTag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public BTag<TDTag> B(object value)
        {
            return B(SafeString(value));
        }
        
        public BlockquoteTag<TDTag> Blockquote()
        {
            var ctrl = new BlockquoteTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag Blockquote(BlockquoteTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public BlockquoteTag<TDTag> Blockquote(string text)
        {
            var ctrl = new BlockquoteTag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public BlockquoteTag<TDTag> Blockquote(Control control)
        {
            var ctrl = new BlockquoteTag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public BlockquoteTag<TDTag> Blockquote(object value)
        {
            return Blockquote(SafeString(value));
        }
        
        public BRTag<TDTag> BR()
        {
            var ctrl = new BRTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag BR(BRTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public DivTag<TDTag> Div()
        {
            var ctrl = new DivTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag Div(DivTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public DivTag<TDTag> Div(string text)
        {
            var ctrl = new DivTag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public DivTag<TDTag> Div(Control control)
        {
            var ctrl = new DivTag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public DivTag<TDTag> Div(object value)
        {
            return Div(SafeString(value));
        }
        
        public EMTag<TDTag> EM()
        {
            var ctrl = new EMTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag EM(EMTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public EMTag<TDTag> EM(string text)
        {
            var ctrl = new EMTag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public EMTag<TDTag> EM(Control control)
        {
            var ctrl = new EMTag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public EMTag<TDTag> EM(object value)
        {
            return EM(SafeString(value));
        }
        
        public H1Tag<TDTag> H1()
        {
            var ctrl = new H1Tag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag H1(H1Tag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public H1Tag<TDTag> H1(string text)
        {
            var ctrl = new H1Tag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public H1Tag<TDTag> H1(Control control)
        {
            var ctrl = new H1Tag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public H1Tag<TDTag> H1(object value)
        {
            return H1(SafeString(value));
        }
        
        public H2Tag<TDTag> H2()
        {
            var ctrl = new H2Tag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag H2(H2Tag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public H2Tag<TDTag> H2(string text)
        {
            var ctrl = new H2Tag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public H2Tag<TDTag> H2(Control control)
        {
            var ctrl = new H2Tag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public H2Tag<TDTag> H2(object value)
        {
            return H2(SafeString(value));
        }
        
        public H3Tag<TDTag> H3()
        {
            var ctrl = new H3Tag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag H3(H3Tag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public H3Tag<TDTag> H3(string text)
        {
            var ctrl = new H3Tag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public H3Tag<TDTag> H3(Control control)
        {
            var ctrl = new H3Tag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public H3Tag<TDTag> H3(object value)
        {
            return H3(SafeString(value));
        }
        
        public H4Tag<TDTag> H4()
        {
            var ctrl = new H4Tag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag H4(H4Tag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public H4Tag<TDTag> H4(string text)
        {
            var ctrl = new H4Tag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public H4Tag<TDTag> H4(Control control)
        {
            var ctrl = new H4Tag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public H4Tag<TDTag> H4(object value)
        {
            return H4(SafeString(value));
        }
        
        public H5Tag<TDTag> H5()
        {
            var ctrl = new H5Tag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag H5(H5Tag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public H5Tag<TDTag> H5(string text)
        {
            var ctrl = new H5Tag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public H5Tag<TDTag> H5(Control control)
        {
            var ctrl = new H5Tag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public H5Tag<TDTag> H5(object value)
        {
            return H5(SafeString(value));
        }
        
        public H6Tag<TDTag> H6()
        {
            var ctrl = new H6Tag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag H6(H6Tag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public H6Tag<TDTag> H6(string text)
        {
            var ctrl = new H6Tag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public H6Tag<TDTag> H6(Control control)
        {
            var ctrl = new H6Tag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public H6Tag<TDTag> H6(object value)
        {
            return H6(SafeString(value));
        }
        
        public HRTag<TDTag> HR()
        {
            var ctrl = new HRTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag HR(HRTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ITag<TDTag> I()
        {
            var ctrl = new ITag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag I(ITag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ITag<TDTag> I(string text)
        {
            var ctrl = new ITag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public ITag<TDTag> I(Control control)
        {
            var ctrl = new ITag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public ITag<TDTag> I(object value)
        {
            return I(SafeString(value));
        }
        
        public ImgTag<TDTag> Img()
        {
            var ctrl = new ImgTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag Img(ImgTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public OLTag<TDTag> OL()
        {
            var ctrl = new OLTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag OL(OLTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public PTag<TDTag> P()
        {
            var ctrl = new PTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag P(PTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public PTag<TDTag> P(string text)
        {
            var ctrl = new PTag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public PTag<TDTag> P(Control control)
        {
            var ctrl = new PTag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public PTag<TDTag> P(object value)
        {
            return P(SafeString(value));
        }
        
        public PreTag<TDTag> Pre()
        {
            var ctrl = new PreTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag Pre(PreTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public PreTag<TDTag> Pre(string text)
        {
            var ctrl = new PreTag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public PreTag<TDTag> Pre(Control control)
        {
            var ctrl = new PreTag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public PreTag<TDTag> Pre(object value)
        {
            return Pre(SafeString(value));
        }
        
        public SpanTag<TDTag> Span()
        {
            var ctrl = new SpanTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag Span(SpanTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SpanTag<TDTag> Span(string text)
        {
            var ctrl = new SpanTag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SpanTag<TDTag> Span(Control control)
        {
            var ctrl = new SpanTag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SpanTag<TDTag> Span(object value)
        {
            return Span(SafeString(value));
        }
        
        public StrongTag<TDTag> Strong()
        {
            var ctrl = new StrongTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag Strong(StrongTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public StrongTag<TDTag> Strong(string text)
        {
            var ctrl = new StrongTag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public StrongTag<TDTag> Strong(Control control)
        {
            var ctrl = new StrongTag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public StrongTag<TDTag> Strong(object value)
        {
            return Strong(SafeString(value));
        }
        
        public SubTag<TDTag> Sub()
        {
            var ctrl = new SubTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag Sub(SubTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SubTag<TDTag> Sub(string text)
        {
            var ctrl = new SubTag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SubTag<TDTag> Sub(Control control)
        {
            var ctrl = new SubTag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SubTag<TDTag> Sub(object value)
        {
            return Sub(SafeString(value));
        }
        
        public SupTag<TDTag> Sup()
        {
            var ctrl = new SupTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag Sup(SupTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SupTag<TDTag> Sup(string text)
        {
            var ctrl = new SupTag<TDTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SupTag<TDTag> Sup(Control control)
        {
            var ctrl = new SupTag<TDTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SupTag<TDTag> Sup(object value)
        {
            return Sup(SafeString(value));
        }
        
        public TableTag<TDTag> Table()
        {
            var ctrl = new TableTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag Table(TableTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ULTag<TDTag> UL()
        {
            var ctrl = new ULTag<TDTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag UL(ULTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        
        public TDTag Text(string text)
        {
            Controls.Add(new LiteralControl(text));
            return this;
        }

        public TDTag Text(object value)
        {
            Controls.Add(new LiteralControl(SafeString(value)));
            return this;
        }
        
    }

    public class TDTag<ParentType> : ChildTag<TDTag<ParentType>, ParentType>
        where ParentType : HtmlGenericControl
    {
        public TDTag(ParentType parent) : base("td", parent) { }

        
        public TDTag<ParentType> Abbr(string value)
        {   
            Attributes.Add("abbr", value.ToString());
            return this;
        }
        
        public TDTag<ParentType> Axis(string value)
        {   
            Attributes.Add("axis", value.ToString());
            return this;
        }
        
        public TDTag<ParentType> Colspan(int value)
        {   
            Attributes.Add("colspan", value.ToString());
            return this;
        }
        
        public TDTag<ParentType> Headers(string value)
        {   
            Attributes.Add("headers", value.ToString());
            return this;
        }
        
        public TDTag<ParentType> Rowspan(int value)
        {   
            Attributes.Add("rowspan", value.ToString());
            return this;
        }
        
        public TDTag<ParentType> Scope(string value)
        {   
            Attributes.Add("scope", value.ToString());
            return this;
        }
        
        
        public string AbbrAttribute
        {
            get
            {
                return Attributes["abbr"];
            }
        }
        
        public string AxisAttribute
        {
            get
            {
                return Attributes["axis"];
            }
        }
        
        public int ColspanAttribute
        {
            get
            {
                int test;
                if (int.TryParse(Attributes["colspan"], out test))
                {
                    return test;
                }

                // the default
                return 1;
            }
        }
        
        public string HeadersAttribute
        {
            get
            {
                return Attributes["headers"];
            }
        }
        
        public int RowspanAttribute
        {
            get
            {
                int test;
                if (int.TryParse(Attributes["rowspan"], out test))
                {
                    return test;
                }

                // the default
                return 1;
            }
        }
        
        public string ScopeAttribute
        {
            get
            {
                return Attributes["scope"];
            }
        }
        
        
        public ATag<TDTag<ParentType>> A()
        {
            var ctrl = new ATag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> A(ATag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ATag<TDTag<ParentType>> A(string text)
        {
            var ctrl = new ATag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public ATag<TDTag<ParentType>> A(Control control)
        {
            var ctrl = new ATag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public ATag<TDTag<ParentType>> A(object value)
        {
            var ctrl = new ATag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public BTag<TDTag<ParentType>> B()
        {
            var ctrl = new BTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> B(BTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public BTag<TDTag<ParentType>> B(string text)
        {
            var ctrl = new BTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public BTag<TDTag<ParentType>> B(Control control)
        {
            var ctrl = new BTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public BTag<TDTag<ParentType>> B(object value)
        {
            var ctrl = new BTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public BlockquoteTag<TDTag<ParentType>> Blockquote()
        {
            var ctrl = new BlockquoteTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> Blockquote(BlockquoteTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public BlockquoteTag<TDTag<ParentType>> Blockquote(string text)
        {
            var ctrl = new BlockquoteTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public BlockquoteTag<TDTag<ParentType>> Blockquote(Control control)
        {
            var ctrl = new BlockquoteTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public BlockquoteTag<TDTag<ParentType>> Blockquote(object value)
        {
            var ctrl = new BlockquoteTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public BRTag<TDTag<ParentType>> BR()
        {
            var ctrl = new BRTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> BR(BRTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public DivTag<TDTag<ParentType>> Div()
        {
            var ctrl = new DivTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> Div(DivTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public DivTag<TDTag<ParentType>> Div(string text)
        {
            var ctrl = new DivTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public DivTag<TDTag<ParentType>> Div(Control control)
        {
            var ctrl = new DivTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public DivTag<TDTag<ParentType>> Div(object value)
        {
            var ctrl = new DivTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public EMTag<TDTag<ParentType>> EM()
        {
            var ctrl = new EMTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> EM(EMTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public EMTag<TDTag<ParentType>> EM(string text)
        {
            var ctrl = new EMTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public EMTag<TDTag<ParentType>> EM(Control control)
        {
            var ctrl = new EMTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public EMTag<TDTag<ParentType>> EM(object value)
        {
            var ctrl = new EMTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public H1Tag<TDTag<ParentType>> H1()
        {
            var ctrl = new H1Tag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> H1(H1Tag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public H1Tag<TDTag<ParentType>> H1(string text)
        {
            var ctrl = new H1Tag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public H1Tag<TDTag<ParentType>> H1(Control control)
        {
            var ctrl = new H1Tag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public H1Tag<TDTag<ParentType>> H1(object value)
        {
            var ctrl = new H1Tag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public H2Tag<TDTag<ParentType>> H2()
        {
            var ctrl = new H2Tag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> H2(H2Tag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public H2Tag<TDTag<ParentType>> H2(string text)
        {
            var ctrl = new H2Tag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public H2Tag<TDTag<ParentType>> H2(Control control)
        {
            var ctrl = new H2Tag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public H2Tag<TDTag<ParentType>> H2(object value)
        {
            var ctrl = new H2Tag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public H3Tag<TDTag<ParentType>> H3()
        {
            var ctrl = new H3Tag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> H3(H3Tag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public H3Tag<TDTag<ParentType>> H3(string text)
        {
            var ctrl = new H3Tag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public H3Tag<TDTag<ParentType>> H3(Control control)
        {
            var ctrl = new H3Tag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public H3Tag<TDTag<ParentType>> H3(object value)
        {
            var ctrl = new H3Tag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public H4Tag<TDTag<ParentType>> H4()
        {
            var ctrl = new H4Tag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> H4(H4Tag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public H4Tag<TDTag<ParentType>> H4(string text)
        {
            var ctrl = new H4Tag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public H4Tag<TDTag<ParentType>> H4(Control control)
        {
            var ctrl = new H4Tag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public H4Tag<TDTag<ParentType>> H4(object value)
        {
            var ctrl = new H4Tag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public H5Tag<TDTag<ParentType>> H5()
        {
            var ctrl = new H5Tag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> H5(H5Tag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public H5Tag<TDTag<ParentType>> H5(string text)
        {
            var ctrl = new H5Tag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public H5Tag<TDTag<ParentType>> H5(Control control)
        {
            var ctrl = new H5Tag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public H5Tag<TDTag<ParentType>> H5(object value)
        {
            var ctrl = new H5Tag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public H6Tag<TDTag<ParentType>> H6()
        {
            var ctrl = new H6Tag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> H6(H6Tag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public H6Tag<TDTag<ParentType>> H6(string text)
        {
            var ctrl = new H6Tag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public H6Tag<TDTag<ParentType>> H6(Control control)
        {
            var ctrl = new H6Tag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public H6Tag<TDTag<ParentType>> H6(object value)
        {
            var ctrl = new H6Tag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public HRTag<TDTag<ParentType>> HR()
        {
            var ctrl = new HRTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> HR(HRTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ITag<TDTag<ParentType>> I()
        {
            var ctrl = new ITag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> I(ITag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ITag<TDTag<ParentType>> I(string text)
        {
            var ctrl = new ITag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public ITag<TDTag<ParentType>> I(Control control)
        {
            var ctrl = new ITag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public ITag<TDTag<ParentType>> I(object value)
        {
            var ctrl = new ITag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public ImgTag<TDTag<ParentType>> Img()
        {
            var ctrl = new ImgTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> Img(ImgTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public OLTag<TDTag<ParentType>> OL()
        {
            var ctrl = new OLTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> OL(OLTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public PTag<TDTag<ParentType>> P()
        {
            var ctrl = new PTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> P(PTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public PTag<TDTag<ParentType>> P(string text)
        {
            var ctrl = new PTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public PTag<TDTag<ParentType>> P(Control control)
        {
            var ctrl = new PTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public PTag<TDTag<ParentType>> P(object value)
        {
            var ctrl = new PTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public PreTag<TDTag<ParentType>> Pre()
        {
            var ctrl = new PreTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> Pre(PreTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public PreTag<TDTag<ParentType>> Pre(string text)
        {
            var ctrl = new PreTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public PreTag<TDTag<ParentType>> Pre(Control control)
        {
            var ctrl = new PreTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public PreTag<TDTag<ParentType>> Pre(object value)
        {
            var ctrl = new PreTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public SpanTag<TDTag<ParentType>> Span()
        {
            var ctrl = new SpanTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> Span(SpanTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SpanTag<TDTag<ParentType>> Span(string text)
        {
            var ctrl = new SpanTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SpanTag<TDTag<ParentType>> Span(Control control)
        {
            var ctrl = new SpanTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SpanTag<TDTag<ParentType>> Span(object value)
        {
            var ctrl = new SpanTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public StrongTag<TDTag<ParentType>> Strong()
        {
            var ctrl = new StrongTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> Strong(StrongTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public StrongTag<TDTag<ParentType>> Strong(string text)
        {
            var ctrl = new StrongTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public StrongTag<TDTag<ParentType>> Strong(Control control)
        {
            var ctrl = new StrongTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public StrongTag<TDTag<ParentType>> Strong(object value)
        {
            var ctrl = new StrongTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public SubTag<TDTag<ParentType>> Sub()
        {
            var ctrl = new SubTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> Sub(SubTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SubTag<TDTag<ParentType>> Sub(string text)
        {
            var ctrl = new SubTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SubTag<TDTag<ParentType>> Sub(Control control)
        {
            var ctrl = new SubTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SubTag<TDTag<ParentType>> Sub(object value)
        {
            var ctrl = new SubTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public SupTag<TDTag<ParentType>> Sup()
        {
            var ctrl = new SupTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> Sup(SupTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SupTag<TDTag<ParentType>> Sup(string text)
        {
            var ctrl = new SupTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SupTag<TDTag<ParentType>> Sup(Control control)
        {
            var ctrl = new SupTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SupTag<TDTag<ParentType>> Sup(object value)
        {
            var ctrl = new SupTag<TDTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public TableTag<TDTag<ParentType>> Table()
        {
            var ctrl = new TableTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> Table(TableTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ULTag<TDTag<ParentType>> UL()
        {
            var ctrl = new ULTag<TDTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public TDTag<ParentType> UL(ULTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        
        public TDTag<ParentType> Text(string text)
        {
            Controls.Add(new LiteralControl(text));
            return this;
        }
        
        public TDTag<ParentType> Text(object value)
        {
            Controls.Add(new LiteralControl(SafeString(value)));
            return this;
        }
        
        
    }
}